# -*- coding: utf-8 -*-
"""
Created on Sat Jun  9 17:31:55 2012

@author: nzhao
"""

from traits.api   import HasTraits, Instance
from traitsui.api import View, Item, Group

from gui.SpinViewer        import SpinViewer
from gui.Axes              import Axes
from gui.cpmg_spin_half_HF import cpmg_spin_half_hf
from gui.cpmg_spin_half    import cpmg_spin_half
from gui.C13Bath           import C13Bath
from gui.LogText           import LogText

class SpinSolver(HasTraits):
    axes           = Instance(Axes)
    spin_viewer    = Instance(SpinViewer)
    cpmg_single_hf = Instance(cpmg_spin_half_hf)
    cpmg_single    = Instance(cpmg_spin_half)
    cpmg_bath      = Instance(C13Bath)
    log_text       = Instance(LogText)
    
    def __init__(self):
        self.axes           = Axes()
        self.spin_viewer    = SpinViewer       (axes= self.axes.axes_list)
        self.cpmg_single_hf = cpmg_spin_half_hf(axes= self.axes.axes_list)
        self.cpmg_single    = cpmg_spin_half   (axes= self.axes.axes_list, multi_spin= self.spin_viewer.multi_spin)
        self.cpmg_bath      = C13Bath          (axes= self.axes.axes_list, multi_spin= self.spin_viewer.multi_spin)


    view = View( 
            Group(Item('spin_viewer',    style = 'custom', show_label=False) ),
            Group(Item('axes',           style = 'custom', show_label=False), label = 'Axes'),
            Group(Item('cpmg_single_hf', style = 'custom', show_label=False), label = 'cpmg-1/2-hf'),            
            Group(Item('cpmg_single',    style = 'custom', show_label=False), label = 'cpmg-1/2'),
            Group(Item('cpmg_bath',      style = 'custom', show_label=False), label = 'cpmg C13 bath'),
            Group(Item('log_text',       style = 'custom', show_label=False), label = 'Log Text'),
            width =0.8,
            height =0.9,
            resizable = True,
            kind = 'live'
    )


if __name__ == '__main__':
    solver1 = SpinSolver()
    solver1.configure_traits()